import ExampleItem from "./ExampleItem";
import XRole from "../../XRole";
import ScrollViewItemBase from "../Util/ScrollViewItemBase";

const { ccclass, property } = cc._decorator;
/**多行多列(一般用来做背包等) */
@ccclass
export default class ExampleLayout extends ScrollViewItemBase {

    //单项下的子物体
    @property([ExampleItem])
    mExampleItem: ExampleItem[] = [];

    onLoad() {
        for (let i = 0; i < this.mExampleItem.length; i++) {
            let childNode = this.mExampleItem[i];
            this.mChildNode.push(childNode.node);
        }
    }

    updateItem(tmplId, itemID) {
        for (let i = 0; i < this.mChildNums; i++) {
            let index = tmplId * this.mChildNums + i;
            this.mExampleItem[i].updateItem(index);
        }
        this.node.active = true;
        //必须赋值,底层列表根据此值计算上下
        this.itemID = tmplId;
    };
}
